from django.utils.deprecation import MiddlewareMixin
from django.shortcuts import HttpResponse

class M1(MiddlewareMixin):
    def process_request(self,request):
        # 如果方法中没有返回值(返回None)，继续向后走
        # 如果有返回值，httpResponse render redirect
        print("M1 process_request")

    def process_response(self,request,response):
        print("M1 process_response")
        return response

class M2(MiddlewareMixin):
    def process_request(self,request):
        # 如果方法中没有返回值(返回None)，继续向后走
        # 如果有返回值，httpResponse render redirect
        print("M2 process_request")

    def process_response(self,request,response):
        print("M2 process_response")
        return response
